package com.lifeng.controller;

import com.lifeng.dto.GoodsInfoDto;
import com.lifeng.dto.GoodsListDto;
import com.lifeng.dto.PhotoCateDto;
import com.lifeng.dto.PhotoDetailDto;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    /**
     * 商品列表
     * */
    @RequestMapping("/list")
    public List<GoodsListDto> cate(){
        List<GoodsListDto> listDtos = new ArrayList<>();
        listDtos.add(
                GoodsListDto.builder()
                .id("1")
                .name("移动联通电信4G手机 双卡双待")
                .kunCun(22)
                .nowPrice(2999.99d)
                .oldPrice(1999.12)
                .imgUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577450780760&di=3e7f813ec4b03096e07d29fa096816b4&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fea216c8584830aefaa63728edabb5b5ccbdbf2ca40ff8-u4akor_fw658")
                .build()
        );
        listDtos.add(
                GoodsListDto.builder()
                        .id("2")
                        .name("三星 Galaxy A90 5G（SM-A9080）")
                        .kunCun(123)
                        .nowPrice(1234.99)
                        .oldPrice(123.33)
                        .imgUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577450780760&di=3e7f813ec4b03096e07d29fa096816b4&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fea216c8584830aefaa63728edabb5b5ccbdbf2ca40ff8-u4akor_fw658")
                        .build()
        );
        listDtos.add(
                GoodsListDto.builder()
                        .id("3")
                        .name("移动联通电信4G手机 双卡双待")
                        .kunCun(777)
                        .nowPrice(1233.45)
                        .oldPrice(344.12)
                        .imgUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577450780760&di=3e7f813ec4b03096e07d29fa096816b4&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fea216c8584830aefaa63728edabb5b5ccbdbf2ca40ff8-u4akor_fw658")
                        .build()
        );
        listDtos.add(
                GoodsListDto.builder()
                        .id("4")
                        .name("三星 Galaxy A90 5G（SM-A9080）")
                        .kunCun(765)
                        .nowPrice(1233.44)
                        .oldPrice(1999.12)
                        .imgUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577450780760&di=3e7f813ec4b03096e07d29fa096816b4&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fea216c8584830aefaa63728edabb5b5ccbdbf2ca40ff8-u4akor_fw658")
                        .build()
        );
        listDtos.add(
                GoodsListDto.builder()
                        .id("5")
                        .name("移动联通电信4G手机 双卡双待")
                        .kunCun(22)
                        .nowPrice(2999.99d)
                        .oldPrice(1999.12)
                        .imgUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577450780760&di=3e7f813ec4b03096e07d29fa096816b4&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fea216c8584830aefaa63728edabb5b5ccbdbf2ca40ff8-u4akor_fw658")
                        .build()
        );
        return listDtos;
    }

    @RequestMapping("/info/{id}")
    public GoodsInfoDto info(@PathVariable("id") String id){
        return GoodsInfoDto.builder()
                .id("1")
                .title("移动联通电信4G手机 双卡双待")
                .goodId("654324543444")
                .kucun(299)
                .addTime(new Date())
                .oldPrice(2999.9)
                .newPrice(1999.8)
                .build();
    }
}
